# component2/SConscript
Import("env")
import os
from pathlib import Path

with open(env["PROJECT_TOOL_S"]) as f:
    exec(f.read())

_SDK_PATH = os.path.normpath(
    os.environ.get("SDK_PATH", str(Path(os.getcwd()) / ".." / ".."))
)
env["GIT_REPO_LISTS"]["ax-samples"] = {
    "url": "https://github.com/AXERA-TECH/ax-samples.git",
    "commit": "146154ca03929a0e119ca53650e3b05fa40c3e7a",
    "path": str(Path(_SDK_PATH) / "github_source" / "ax-samples"),
}

if "CONFIG_AX_SAMPLES_ENABLED" in os.environ:
    check_component("ax-samples")
    SRCS = []
    INCLUDE = []
    PRIVATE_INCLUDE = []
    REQUIREMENTS = []
    STATIC_LIB = []
    DYNAMIC_LIB = []
    DEFINITIONS = []
    DEFINITIONS_PRIVATE = []
    LDFLAGS = []
    LINK_SEARCH_PATH = []

    INCLUDE += [
        os.path.join(env["GIT_REPO_LISTS"]["ax-samples"]["path"], "examples"),
    ]
    if "CONFIG_AX_620E_MSP_ENABLED" in os.environ:
        INCLUDE += [
            os.path.join(
                env["GIT_REPO_LISTS"]["ax-samples"]["path"],
                "examples/ax620e",
            )
        ]

    env["COMPONENTS"].append(
        {
            "target": os.path.basename(env["component_dir"]),
            "SRCS": SRCS,
            "INCLUDE": INCLUDE,
            "PRIVATE_INCLUDE": PRIVATE_INCLUDE,
            "REQUIREMENTS": REQUIREMENTS,
            "STATIC_LIB": STATIC_LIB,
            "DYNAMIC_LIB": DYNAMIC_LIB,
            "DEFINITIONS": DEFINITIONS,
            "DEFINITIONS_PRIVATE": DEFINITIONS_PRIVATE,
            "LDFLAGS": LDFLAGS,
            "LINK_SEARCH_PATH": LINK_SEARCH_PATH,
            "REGISTER": "static",
        }
    )
